﻿#ifndef NSSHARE_UTILS_BITWISE_ENUM_H_
#define NSSHARE_UTILS_BITWISE_ENUM_H_

namespace nsshare
{
namespace utils
{

template<typename T>
class BitwiseEnum
{
public:
    BitwiseEnum()
    {
        value_ = static_cast<T>(0);
    }
    ~BitwiseEnum()
    {
    }

    //implicit type convertion
    BitwiseEnum(T value)
        :value_(value)
    {
    }

    BitwiseEnum(int value)
    {
        value_ = static_cast<T>(value);
    }

    operator T() const
    {
        return value_;
    }

    void BitwiseEnum::operator |= (const int obj)
    {
        value_ = static_cast<T>(value_ | obj);
    }

    void BitwiseEnum::operator &= (const int obj)
    {
        value_ = static_cast<T>(value_ & obj);
    }

private:
    T value_;
};

}
}
#endif